
package com.primeton.eos.oss.model.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eos.system.utility.PageResultList;

import com.eos.data.datacontext.DataContextManager;
import com.eos.data.datacontext.IMUODataContext;

import com.primeton.eos.oss.model.dao.AfcEmployeeDao;
import com.primeton.eos.oss.model.newdataset.AfcEmployee;

@Service
public class AfcEmployeeService {

    @Autowired
    private AfcEmployeeDao afcEmployeeDao;


    public PageResultList<AfcEmployee> queryAfcEmployeesWithPage(String code,  int pageSize, int pageIndex) {
        //TODO 记录日志
        return afcEmployeeDao.queryAfcEmployeesWithPage(code,  pageSize, pageIndex);
    }

    public AfcEmployee getAfcEmployeeById(String id) {
        //TODO 记录日志
        return afcEmployeeDao.getEntity(AfcEmployee.QNAME, id);
    }

    @Transactional
    public void createAfcEmployee(AfcEmployee afcEmployee) {
        //TODO 记录日志
    	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        afcEmployee.set("createUser", userName);
        afcEmployee.set("createTime", new Date());
        afcEmployee.set("updateUser", userName);
        afcEmployee.set("updateTime", new Date());

        afcEmployeeDao.getPrimaryKey(afcEmployee);
        afcEmployeeDao.insertEntity(afcEmployee);
    }
    
    @Transactional
    public void modifyAfcEmployee(AfcEmployee afcEmployee) {
        //TODO 记录日志
     	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        afcEmployee.set("updateUser", userName);
        afcEmployee.set("updateTime", new Date());
 
        afcEmployeeDao.updateEntity(afcEmployee);
    }
    
     @Transactional
    public void removeAfcEmployee(AfcEmployee[] afcEmployee) {
        //TODO 记录日志
        afcEmployeeDao.deleteEntity(afcEmployee);
    }

}





